/**
 * 
 */
package edu.scsu.csci.core;


/**
 * A wrapper for command class and Action clazz method's name.
 * 
 * @author Maqbool Khan
 * @since jdk 1.5
 * @see
 * @viz.diagram ActionURL.tpx
 */
public class ActionURL {
	
	/**
	 * action class name.
	 */
	private final String actionName;
	
	/**
	 * action clazz method's name.
	 */
	private final String stratergyName;
	
	/**
	 * to cache the hashcode.
	 */
	private volatile int hashCode = 0;  
	
	/**
	 * @param actionName
	 * @param stratergyName
	 */
	public ActionURL(String commandName, String stratergyName) {
		this.actionName = commandName;
		this.stratergyName = stratergyName;
	}

	/**
	 * Returns action name.
	 * @return Returns actionName.
	 */
	public String getActionName() {
		return actionName;
	}
	
	/**
	 * Returns stratergyName.
	 * @return Returns stratergyName.
	 */
	public String getStratergyName() {
		return stratergyName;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj){
		if(this == obj){
			return true;
		}
		
		if((!(obj instanceof ActionURL)) || obj == null){
			return false;
		}
		
		ActionURL object = (ActionURL) obj;
		return object.getActionName().equalsIgnoreCase(this.actionName) 
				&& object.getStratergyName().equalsIgnoreCase(this.stratergyName)? true : false;
	}

	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
	    if (hashCode == 0) {
	        int result = 17;
	        result = 37*result + this.actionName.hashCode();
	        result = 37*result + this.stratergyName.hashCode();
	        hashCode = result;
	    }
	    return hashCode;
	}
}
